<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        * {margin:0; padding: 0}
        ul {list-style: none;}
        body {
            background-color: #333;
        }
        .nav {
            width: 800px;
            height: 42px;
            margin: 100px auto;
            background: url(images/rss.png) right center no-repeat #fff;
            border-radius: 10px;
            position: relative;
        }
        .nav ul li{
            width: 83px;
            height: 42px;
            float: left;
            line-height: 42px;
            text-align: center;
            cursor: pointer;
        }
        .nav span {
            width: 83px;
            height: 42px;
            background: url(images/cloud.gif) no-repeat;
            position: absolute;
            left: 0;
            top: 0;
        }
        .nav  ul {
            position: absolute;
        }
    </style>
    <script src="../../js/jquery.js"></script>
</head>
<body>
<div class="nav">
    <span class="cloud"></span>
    <ul>
        <li>北京校区</li>
        <li>北京校区</li>
        <li>北京校区</li>
        <li>北京校区</li>
        <li>北京校区</li>
        <li>北京校区</li>
        <li>北京校区</li>
        <li>北京校区</li>
    </ul>
    <script>
        $.fn.extend({
            move(){
                var $w=$(this).find("li").width()
                let $flag=0

                this.find("ul").on("mouseenter","li",function(){
                    var $count=$(this).index()
                    $(".cloud").stop().animate({
                        left:$count*$w
                    })

                    for(var i=0;i<$("li").length;i++){
                        $(this).eq(i).on("click",function(){
                            $flag=$(this).index()
                            $(".cloud").css({
                                left:$flag*$w
                            })
                        })
                        return $flag;
                    }
                })
                this.find("ul").on("mouseleave",function(){
                    $(".cloud").stop().animate({
                        left:$flag*$w
                    })
                })
            }
        })

        $(function(){
            $(".nav").move()
        })
    </script>
</div>
</body>
</html>